import sqlobject
from coptur.database import *

class Site(sqlobject.SQLObject):

    _connection = connection.connect

    #name = sqlobject.StringCol(length=14, unique=True)
    #lastCall = sqlobject.DateTimeCol(default=None)
    name = sqlobject.StringCol(length=255)
    entry = sqlobject.StringCol(length=255)
    urls = sqlobject.MultipleJoin('Url', joinColumn='site_id')
    task = sqlobject.ForeignKey('Task')

# create table if not exists
Site.createTable(ifNotExists=True)


'''
Query
from models.site import site
from models.url import url

xxx = Site(name='xxx.com')
url = Url(link="xxx", site=xxx)


for url in xxx.urls:
    print url.link
'''
